package com.gljx.web.service.impl;

import com.gljx.constant.ActivitiKey;
import com.gljx.util.ActitiviUtil;
import com.gljx.util.GetFid;
import com.gljx.util.GetFnumber;
import com.gljx.util.GetUserSession;
import com.gljx.web.Entity.*;
import com.gljx.web.dao.*;
import com.gljx.web.service.CoaceGroupService;
import com.gljx.web.service.CustomLogService;
import com.gljx.web.service.PersonService;
import com.gljx.web.service.SharecarthreeregService;
import org.apache.commons.collections.ArrayStack;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.*;

import static com.gljx.util.BigDecimalUtil.NullToBigDecimal;

/**
 * Created by Administrator on 2017/11/20 0020.
 */
@Transactional
@Service
public class SharecarthreeregServiceImpl extends CommonDao implements SharecarthreeregService {
    @Autowired
    SharecarthreeregMapper sharecarthreeregMapper;
    @Autowired
    SharecarthreeregentryMapper sharecarthreeregentryMapper;
    @Autowired
    StudentMapper studentMapper;
    @Autowired
    CustomLogService customLogService;
    @Autowired
    HttpSession session;
    @Autowired
    ExerciseCarPlanMapper exerciseCarPlanMapper;
    @Autowired
    CoaceGroupService coaceGroupService;
    //自动注入
    @Autowired
    private PersonService personService;
    @Autowired
    CarMapper carMapper;
    @Autowired
    CoachsubMapper coachsubMapper;


    @Override
    public List<Sharecarthreeregentry> selectSharecarthreeregentryByFid(String fid, String cfstudentname) {
        return sharecarthreeregentryMapper.selectSharecarthreeregentryByFparentid(fid, cfstudentname);
    }

    @Override
    public Map<String, Object> selectPageCount(String psql) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("Psql", psql);
        paramMap.put("Pcount", oracle.jdbc.OracleTypes.INTEGER);
        this.getSqlSession().select("com.gljx.web.dao.SharecarthreeregMapper.pagecount", paramMap, null);
        return paramMap;
    }

    /**
     * @Author lcx
     * @Date 2017/11/21 0021 上午 11:45
     * 根据教练的fid查询教练的 名称 手机 车型 车牌号 教练组 教练组编码
     */
    @Override
    public Sharecarthreeregentry queryPersonCarByFid(String id) {
        return sharecarthreeregentryMapper.selectPersonCarByFid(id);
    }


    /**
     * @Author lcx
     * @Date 2017/11/23 0023 下午 2:14
     * 删除科目三分车
     */
    @Override
    public void deleteBySharecarthreeregKey(String[] deleteId, String[] fnumber) {
        ActitiviUtil actitiviUtil = new ActitiviUtil();
        User user = (User)session.getAttribute("user");
        for (int i = 0; i < deleteId.length; i++) {

            //添加学员服务日志
            List<Sharecarthreeregentry> sharecartworegentries = sharecarthreeregentryMapper.selectSharecarthreeregentryByFparentidAsthree(deleteId[i]);

            for (Sharecarthreeregentry sharecarthreeregentry : sharecartworegentries) {
                customLogService.addLog("科目三分车进行删除", "删除了学员:" +
                                sharecarthreeregentry.getCfstudentno() + sharecarthreeregentry.getXyname() + "科目三分车!申请车型:"
                                + sharecarthreeregentry.getCfsqzjcx() + "分车时间:" + sharecarthreeregentry.getFbizdate()
                                + "单据编号：" + sharecarthreeregentry.getFnumber(),
                        sharecarthreeregentry.getCfstudentid(), ((User) session.getAttribute("user")).getFid());
            }

            actitiviUtil.deleteTask(ActivitiKey.Driving_GL_ID.equals(user.getFcompanyid()) ? ActivitiKey.FNUMBER_KM3FC_GL : ActivitiKey.FNUMBER_KM3FC_NC, fnumber[i]);
            sharecarthreeregMapper.deleteByPrimaryKey(deleteId[i]);
            sharecarthreeregentryMapper.deleteByFparentid(deleteId[i]);
        }
    }

    /**
     * @Author lcx
     * @Date 2017/11/23 0023 下午 2:39
     * 查询科目二分车信息
     */
    @Override
    public Sharecarthreereg selectSharecarthreeregByFid(String fid) {

        Sharecarthreereg sharecarthreereg = sharecarthreeregMapper.selectByPrimaryKey(fid);
        //此方法查询的内容不是外面列表查询的内容是点击查看的内容
        if (sharecarthreereg != null) {
            sharecarthreereg.setSharecarthreeregentryList(sharecarthreeregentryMapper.selectSharecarthreeregentryByFparentidAsthree(fid));
        }

        return sharecarthreereg;
    }

    @Override
    public Sharecarthreeregentry selectShareCarthreeregenByName(String cfstudentname) {

        return sharecarthreeregentryMapper.selectShareCarthreeregenByName(cfstudentname);
    }

    @Override
    public void addsharecarthreereg(String state, Sharecarthreereg sharecarthreereg, String[] fseq, String[] jlznamebm, String[] jlzname, String[] cfduizhang, String[] jlname, String[] cfcoachphone, String[] cfcarcx, String[] cfcarnumber, String[] cfstudentid, String[] xyname, String[] cfstudentno, String[] cfidcardno, String[] cfstuvip, String[] cfstubillstate, String[] cffristexam, String[] cfkmesgsj, String[] cfsex, String[] cfkmsbjgsj, String[] cfkmskscs, String[] cfphone, String[] cfmobile, String[] cfsqzjcx, String[] cfbdyd, String[] cfpxlx, String[] cftjr, String[] cfclazz, String[] cfyishou, String[] cfysje, String[] cfyouhui, String[] cfqianfei, String[] cfremark) {
        //删除老的信息在次添加
        if ("1".equals(state)) {
            //查询之前的信息
            Sharecarthreereg sharecarthreeregtem = sharecarthreeregMapper.selectByPrimaryKey(sharecarthreereg.getFid());
            sharecarthreereg.setFcreatorid(sharecarthreeregtem.getFcreatorid());
            sharecarthreereg.setFcreatetime(sharecarthreeregtem.getFcreatetime());
            //sharecarthreeregMapper.deleteByPrimaryKey(sharecarthreereg.getFid());
            sharecarthreeregentryMapper.deleteByFparentid(sharecarthreereg.getFid());
            //为了消除提交页面点击确定丢失审核人的 问题
            if ("2".equals(sharecarthreereg.getFfivouchered() + "")) {
                sharecarthreereg.setFauditorid(sharecarthreeregtem.getFauditorid());
                sharecarthreereg.setCfbillstate(Long.valueOf("3"));
            }
        }

        /*获取uuid*/
        String uuid = GetFid.UUIDIntoFid();
        if (cfstudentid != null || cfstudentid.length != 0) {
            //添加子类

            for (int i = 0; i < cfstudentid.length; i++) {
                Sharecarthreeregentry sharecarthreeregentry = new Sharecarthreeregentry();

                sharecarthreeregentry.setFid(GetFid.UUIDIntoFid());
                if ("1".equals(state)) {
                    sharecarthreeregentry.setFparentid(sharecarthreereg.getFid());
                } else {
                    sharecarthreeregentry.setFparentid(uuid);
                }
                sharecarthreeregentry.setFseq(Long.valueOf(fseq[i]));
                sharecarthreeregentry.setCfjlgroupid(jlzname[i]);
                sharecarthreeregentry.setCfjsgroupno(jlznamebm[i]);
                sharecarthreeregentry.setCfcoachid(jlname[i]);
                //（0：是1:否）
                sharecarthreeregentry.setCfduizhang(Long.valueOf(cfduizhang[i]));
                sharecarthreeregentry.setJlname(jlname[i]);
                sharecarthreeregentry.setCfcoachphone(cfcoachphone[i]);
                sharecarthreeregentry.setCfcarcx(cfcarcx[i]);
                sharecarthreeregentry.setCfcarnumber(cfcarnumber[i]);
                sharecarthreeregentry.setCfstudentid(cfstudentid[i]);
                sharecarthreeregentry.setCfstudentno(cfstudentno[i]);
                sharecarthreeregentry.setCfidcardno(cfidcardno[i]);
                //（0：是1:否）
                sharecarthreeregentry.setCfstuvip(Long.valueOf(cfstuvip[i]));
                sharecarthreeregentry.setCfbillstustate(Long.valueOf(cfstubillstate[i]));
                sharecarthreeregentry.setCffristexam(cffristexam[i]);
                sharecarthreeregentry.setCfkmesgsj(cfkmesgsj[i]);//科目二合格时间
                if ("男".equals(cfsex[i])) {
                    sharecarthreeregentry.setCfsex(1L);
                } else {
                    sharecarthreeregentry.setCfsex(2L);
                }
                sharecarthreeregentry.setCfkmskscs(Long.valueOf("".equals(cfkmskscs[i]) || "null".equals(cfkmskscs[i])? "0" : cfkmskscs[i] ));//科目三考试次数
                sharecarthreeregentry.setCfkmsbjgsj(cfkmsbjgsj[i]);//科目三不及格时间
                sharecarthreeregentry.setCfphone(cfphone[i]);
                sharecarthreeregentry.setCfmobile(cfmobile[i]);
                sharecarthreeregentry.setCfsqzjcx(cfsqzjcx[i]);
                if ("本地".equals(cfbdyd[i])) {
                    sharecarthreeregentry.setCfbdyd(1L);
                } else {
                    sharecarthreeregentry.setCfbdyd(2L);
                }
                sharecarthreeregentry.setCfpxlx(cfpxlx[i]);
                sharecarthreeregentry.setCftjr(cftjr[i]);
                sharecarthreeregentry.setCfclazz(cfclazz[i]);
                if (StringUtils.isNotEmpty(cfyishou[i])) {
                    sharecarthreeregentry.setCfyishou(new BigDecimal(NullToBigDecimal(cfyishou[i])));
                }
                if (StringUtils.isNotEmpty(cfysje[i])) {

                    sharecarthreeregentry.setCfysje(new BigDecimal(NullToBigDecimal(cfysje[i])));
                }
                if (StringUtils.isNotEmpty(cfyouhui[i])) {
                    sharecarthreeregentry.setCfyouhui(new BigDecimal(NullToBigDecimal(cfyouhui[i])));
                }
                if (StringUtils.isNotEmpty(cfqianfei[i])) {

                    sharecarthreeregentry.setCfqianfei(new BigDecimal(NullToBigDecimal(cfqianfei[i])));
                }
                sharecarthreeregentry.setCfremark(cfremark[i]);

                sharecarthreeregentryMapper.insertSelective(sharecarthreeregentry);
                if ("1".equals(state)) {
                    //添加学员服务日志
                    customLogService.addLog("科目三分车进行修改", "修改了学员:" +
                                    sharecarthreeregentry.getCfstudentno() + xyname[i] + "科目三分车!申请车型:" + cfsqzjcx[i]
                                    + "分车时间:" + sharecarthreereg.getFbizdate() + "单据编号：" + sharecarthreereg.getFnumber(),
                            sharecarthreeregentry.getCfstudentid(), ((User) session.getAttribute("user")).getFid());

                } else {
                    customLogService.addLog("科目三分车进行新增", "新增了学员:" +
                                    sharecarthreeregentry.getCfstudentno() + xyname[i] + "科目三分车!申请车型:" + cfsqzjcx[i]
                                    + "分车时间:" + sharecarthreereg.getFbizdate() + "单据编号：" + sharecarthreereg.getFnumber(),
                            sharecarthreeregentry.getCfstudentid(), ((User) session.getAttribute("user")).getFid());
                }

            }
            if ("1".equals(state)) {
                sharecarthreeregMapper.updateByPrimaryKeySelective(sharecarthreereg);
            } else {
                sharecarthreereg.setFid(uuid);
                sharecarthreeregMapper.insertSelective(sharecarthreereg);
            }
        }


    }

    @Override
    public Long selectStudentstateAsLcsjAndStudentId(String cflcsjid, String studentid) {
        return sharecarthreeregMapper.selectStudentstate(cflcsjid, studentid);

    }

    /**
     * @Author lcx
     * @Date 2018/3/13 0013 上午 11:22
     * 导出结果集 xls
     */
    @Override
    public List<Sharecarthreeregentry> selectSharecarthreeregAsXls(String fnumber, String fdescription, String cfstudentname, String beginTime, String endTime, String fcompanyid) {
        return sharecarthreeregMapper.selectSharecarthreeregAsXls(fnumber, fdescription, cfstudentname, beginTime, endTime, fcompanyid);
    }

    @Override
    public void importPracticeDrivingData(List<List<Object>> list, Sharecarthreereg sharecarthreereg, List<List<Sharecarsub>> bigsharecarsubList, HttpServletRequest request,List<List<SubjectTwoResult>> bigSubjectrResult) {
        String lctime=""+list.get(0).get(1);//练车时间表
//        studentMapper.selectStudentByCfidcardno(null);//学员身份证查询
////        carMapper.selectCarByName2(null);//车辆表

//      //学员们的状态
        String[] fseq=new String[list.size()-2];//学员排序号码
        String[] cfstudentid=new String[list.size()-2];//学员id
        String[] xyname=new String[list.size()-2];//学员名称
        String[] cfstudentno=new String[list.size()-2];//学员编号
        String[] cfidcardno=new String[list.size()-2];//学员身份证号码
        String[] cfstuvip=new String[list.size()-2];//是否是vip
        String[] cfstubillstate=new String[list.size()-2];//学员状态
        String[] cffristexam=new String[list.size()-2];//出或补
        String[] cfsex=new String[list.size()-2];//学员性别
        String[] cfkmsbjgsj=new String[list.size()-2];//上次考试不及格的时间
        String[] cfkmesgsj=new String[list.size()-2];//科目二合格时间
        String[] cfphone=new String[list.size()-2];//学员电话号码
        String[] cfmobile=new String[list.size()-2];//学员手机号码
        String[] cfsqzjcx=new String[list.size()-2];//申请类型
        String[] cfbdyd=new String[list.size()-2];//本地异地
        String[] cfpxlx=new String[list.size()-2];//培训类型
        String[] cftjr=new String[list.size()-2];//推荐人
        String[] cfclazz=new String[list.size()-2];//班级
        String[] cfyishou=new String[list.size()-2];//应收
        String[] cfysje=new String[list.size()-2];//已收
        String[] cfyouhui=new String[list.size()-2];//优惠
        String[] cfqianfei=new String[list.size()-2];//欠费
        String[] cfkmskscs=new String[list.size()-2];//考试后次数
//        //教练组
        String[] jlznamebm=new String[list.size()-2];//教练组编码
        String[] jlzname=new String[list.size()-2];//教练组名称
        String[] cfduizhang=new String[list.size()-2];//教练是否是组长
//       //教练们
        String[] jlname=new String[list.size()-2];//教练名
        String[]jlId=new String [list.size()-2];
        String[] cfcoachphone=new String[list.size()-2];//教练电话号码
//        //车辆的情况
        String[] cfcarcx=new String[list.size()-2];//车型
        String[] cfcarnumber=new String[list.size()-2];//车牌号
      String[] cfremark=new String[list.size()-2];//备注
        String[]companyId=new String[list.size()-2];
//
        int j=0;
        for (int i = 2; i < list.size(); i++) {
            cfcarnumber[j]= (String) list.get(i).get(0);//车号
            jlname[j] = (String)list.get(i).get(1);//教练员名称
            cfidcardno[j]= (String) list.get(i).get(2);//学员身份证号
            xyname[j]= (String) list.get(i).get(3);//学员姓名
            fseq[j]=String.valueOf(j+5);
            j++;
        }
        for(int i=0;i<bigsharecarsubList.size();i++) {
            for (Sharecarsub sharecarsub : bigsharecarsubList.get(i)) {
                cfstudentno[i] = sharecarsub.getXsfnumber();//学员号码
                cfsqzjcx[i]=sharecarsub.getCfsqzjcxdh();//申请准驾车型 c1
                cfmobile[i] = String.valueOf(sharecarsub.getCfmobile());//手机号码
             if(sharecarsub.getCfphone()==null){
                 cfphone[i] ="";
             }else{
                 cfphone[i] = String.valueOf(sharecarsub.getCfphone());//电话号码
             }

                cfcarcx[i] = sharecarsub.getCfsqzjcxdh();//车型

                cfclazz[i] = sharecarsub.getClassname();//班级名称

                cfremark[i] = "科目三导入";//科目几

                if(sharecarsub.getCfkscs()==null||sharecarsub.getCfkscs()<=0l){
                    cfkmskscs[i]="0";
                }else{
                    cfkmskscs[i]= String.valueOf(sharecarsub.getCfkscs());
                }//考试次数
                cfyishou[i]= String.valueOf(sharecarsub.getCfamount());//应收
                cfysje[i]= String.valueOf(sharecarsub.getCfreceived());//已收
                 cfyouhui[i]= String.valueOf(sharecarsub.getCffavorable());//优惠
                cfqianfei[i]= String.valueOf(sharecarsub.getCfarrearage());//欠费
         if(sharecarsub.getCfkscs()!=null){
             if(sharecarsub.getCfkscs()==1){
                 cffristexam[i]="初次";
             }else if(sharecarsub.getCfkscs()>1){
                 cffristexam[i]="补考";
             }
         }else{
             cffristexam[i]=" ";
         }
                companyId[i]= GetUserSession.getUserSession(request);

            }
        }
//        cffristexam[i]
        List<List<Person>> listPersonBig=new ArrayList<>();
        List< List<Coachsub>> listCoachGroup=new ArrayList<>();
        for(int i=0;i<jlname.length;i++){
         List<Person> people= personService.selectPersonForByName(jlname[i].trim(),companyId[i]);
          listPersonBig.add(people);
          List<Coachsub> coaceGroups=coachsubMapper.selectCoachSubAsXls(jlname[i].trim(),"","","",companyId[i]);
            listCoachGroup.add(coaceGroups);
        }

       for(int i=0;i<jlname.length;i++){
           for(Person person:listPersonBig.get(i)){
                 cfcoachphone[i]= (String) person.getCfcell();
               jlId[i]=person.getFid();

           }
         if(listCoachGroup.get(i).size()==0){
             jlznamebm[i]= null;
             jlzname[i]=  null;
             cfduizhang[i]= "0";

           }else{
           for(Coachsub coaceGroup:listCoachGroup.get(i)){
               if(coaceGroup.getFnumber().equals("")||coaceGroup.getCheckName().equals("")||coaceGroup.getFhandlerid().equals("")){
                   jlznamebm[i]= " ";
                   jlzname[i]=  " ";
                   cfduizhang[i]= " ";
               }else{

               jlznamebm[i]= (String) coaceGroup.getFnumber();
               jlzname[i]=  coaceGroup.getCheckName();
               cfduizhang[i]= coaceGroup.getFhandlerid();

               }
           }
          }
        }
        List<List<Student>> listStudentBig=new ArrayList<>();
        for(int i=0;i<xyname.length;i++){
            List<Student> studentListi= studentMapper.selectStudentByCfidcardno(cfidcardno[i].trim());
           listStudentBig.add(studentListi);
        }
        for(int i=0;i<xyname.length;i++){

          for(Student student:listStudentBig.get(i)){
              cfstudentid[i]=student.getFid();
              if(student.getCfstudentstate()==null|| "".equals(student.getCfstudentstate())){
              cfstubillstate[i]="0";

              }else{
                  cfstubillstate[i]= String.valueOf(student.getCfstudentstate());
              }

              if(student.getCfvip()==null||"".equals(student.getCfvip())){
                  cfstuvip[i] ="0";
              }else{
                  cfstuvip[i] = student.getCfvip();
              }

              cfbdyd[i]= String.valueOf(student.getCflocal());
               if(cfbdyd[i].equals("1")){
                   cfbdyd[i]="本地";
               }else{
                   cfbdyd[i]="异地";
               }

//               if(student.getCftrainTypeNAME()==null||"".equals(student.getCftrainTypeNAME())){
//                   cfpxlx[i]=lctime;
//               }else{
//
//              cfpxlx[i]=student.getCftrainTypeNAME();
//               }
               if(student.getCftjrid()==null||"".equals(student.getCftjrid())){
                   cftjr[i]="";
               }else{

              cftjr[i]=student.getCftjrid();
               }


              if(student.getCfsex()==1){
                  cfsex[i]="男";
              }else{
                  cfsex[i]="女";
              }
             if(student.getCfkmsbjgsj()==null){
                 cfkmsbjgsj[i]="";
             }else{
                 cfkmsbjgsj[i]=student.getCfkmsbjgsj();
             }
              cfkmesgsj[i]=student.getCfkmehgrq();
             cfkmsbjgsj[i]=student.getCfkmebjgsj();

          }
        }
        String []tjrName=new String[list.size()-2];
          for(int i=0;i<cftjr.length;i++){
              Person person=personService.selTrainTypeById(cftjr[i].trim());
              tjrName[i]= (String) person.getFnameL2();
          }

         /* for(int i=0;i<cfkmesgsj.length;i++){

              for(SubjectTwoResult subjectTwoResult:bigSubjectrResult.get(i)){
                  cfkmesgsj[i]=subjectTwoResult.getFbizdate();
              }

          }*/
           String lctimeId=exerciseCarPlanMapper.selectByfunmber(lctime,GetUserSession.getUserSession(request));
           sharecarthreereg.setCfbillstate(3L);
           sharecarthreereg.setCflcsjid(lctimeId);
           String fnumber = GetFnumber.fnumbers("FCS");
           sharecarthreereg.setFnumber(fnumber);
           sharecarthreereg.setFdescription("科目三导入的分车");

        addsharecarthreereg("0",sharecarthreereg, fseq, jlznamebm, jlzname,  cfduizhang,  jlId,  cfcoachphone,cfcarcx,cfcarnumber, cfstudentid,xyname,cfstudentno,cfidcardno,  cfstuvip, cfstubillstate,cffristexam,cfkmesgsj,  cfsex, cfkmsbjgsj, cfkmskscs, cfphone, cfmobile,cfsqzjcx,cfbdyd, cfpxlx, tjrName, cfclazz,  cfyishou, cfysje,  cfyouhui,cfqianfei,cfremark);
    }



    /**
     * @Author lcx
     * @Date 2018/2/23 0023 上午 11:03
     * studentId 学生id  cfstubillstateid 学生状态
     */
    @Override
    public void modifyStudentsState(String[] cfstudentid, String[] cfstubillstateid, String cflcsjid) {
        for (int i = 0; i < cfstudentid.length; i++) {
            Student student = new Student();
            student.setFid(cfstudentid[i]);
            //修改学生表中的练车时间id
            student.setCfkmslcsjid(cflcsjid);

            String cfstubillstateids = "";


            //如果是 批量审核则查询数据库 中的学生状态
            if (cfstubillstateid.length == 0){
                Student student1 = studentMapper.selectStudentById(cfstudentid[i]);
                if (student != null) {
                    cfstubillstateids = String.valueOf(student1.getCfstudentstate());
                }
            }
            else {
                cfstubillstateids = cfstubillstateid[i];
            }

            if ("2".equals(cfstubillstateids) || "21".equals(cfstubillstateids)) {
                student.setCfstudentstate(Long.valueOf("16"));
            }
            if ("4".equals(cfstubillstateids) || "7".equals(cfstubillstateids) || "8".equals(cfstubillstateids)) {
                student.setCfstudentstate(Long.valueOf("9"));
            }
            if ("5".equals(cfstubillstateids) || "20".equals(cfstubillstateids)) {
                student.setCfstudentstate(Long.valueOf("15"));
            }

            studentMapper.updateByPrimaryKeySelective(student);
        }
    }

    /**
     * @Author lcx
     * @Date 2018/3/9 0009 下午 5:40
     * 反审核
     */
    @Override
    public void modifyStudentsState2(String[] cfstudentid, String[] cfstubillstateid, String cflcsjid) {
        for (int i = 0; i < cfstudentid.length; i++) {
            Student student = new Student();
            student.setFid(cfstudentid[i]);
            //修改学生表中的练车时间id
            student.setCfkmslcsjid(cflcsjid);
            student.setCfstudentstate(Long.valueOf(cfstubillstateid[i]));

            studentMapper.updateByPrimaryKeySelective(student);
        }
    }


    /**
     * @Author lcx
     * @Date 2018/2/26 0026 下午 3:54
     * 添加服务日志 String state 1 提交 2 审核 3 反审核
     */
    public void addLog(String fid, String state) {

        List<Sharecarthreeregentry> sharecarthreeregentries = sharecarthreeregentryMapper.selectSharecarthreeregentryByFparentid(fid, "");

        for (Sharecarthreeregentry sharecarthreeregentry : sharecarthreeregentries) {

            if ("1".equals(state)) {
                customLogService.addLog("科目三分车进行提交", "提交了学员:" +
                                sharecarthreeregentry.getCfstudentno() + sharecarthreeregentry.getXyname() + "科目三分车!申请车型:"
                                + sharecarthreeregentry.getCfsqzjcx() + "分车时间:" + sharecarthreeregentry.getFbizdate()
                                + "单据编号：" + sharecarthreeregentry.getFnumber(),
                        sharecarthreeregentry.getCfstudentid(), ((User) session.getAttribute("user")).getFid());
            }
            if ("2".equals(state)) {
                customLogService.addLog("科目三分车进行审核", "审核了学员:" +
                                sharecarthreeregentry.getCfstudentno() + sharecarthreeregentry.getXyname() + "科目三分车!申请车型:"
                                + sharecarthreeregentry.getCfsqzjcx() + "分车时间:" + sharecarthreeregentry.getFbizdate()
                                + "单据编号：" + sharecarthreeregentry.getFnumber(),
                        sharecarthreeregentry.getCfstudentid(), ((User) session.getAttribute("user")).getFid());
            }
            if ("3".equals(state)) {
                customLogService.addLog("科目三分车进行反审核", "反审核了学员:" +
                                sharecarthreeregentry.getCfstudentno() + sharecarthreeregentry.getXyname() + "科目三分车!申请车型:"
                                + sharecarthreeregentry.getCfsqzjcx() + "分车时间:" + sharecarthreeregentry.getFbizdate()
                                + "单据编号：" + sharecarthreeregentry.getFnumber(),
                        sharecarthreeregentry.getCfstudentid(), ((User) session.getAttribute("user")).getFid());
            }

        }
    }

    @Override
    public Map<String, Object> selectPage(int pindex, String psql, int psize) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("Pindex", pindex);
        paramMap.put("Psql", psql);
        paramMap.put("Psize", psize);
        paramMap.put("Pcount", oracle.jdbc.OracleTypes.INTEGER);
        paramMap.put("v_cur", oracle.jdbc.OracleTypes.CURSOR);
        this.getSqlSession().select("com.gljx.web.dao.SharecarthreeregMapper.pagemap", paramMap, null);
        return paramMap;
    }
}
